//
//  StuUserCell.m
//  test
//
//  Created by 朱圳 on 2017/12/21.
//  Copyright © 2017年 朱圳. All rights reserved.
//

#import "StuUserCell.h"

@implementation StuUserCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createUI];
    }
    return self;
}
-(void)createUI{

    UIImageView *tximg = [[UIImageView alloc]init];
    tximg.image = [UIImage imageNamed:@"头像"];
    [self.contentView addSubview:tximg];
    [tximg mas_makeConstraints:^(MASConstraintMaker *make) {
        [make.left.mas_equalTo(self.contentView.mas_left) setOffset:28];
        [make.top.mas_equalTo(self.contentView.mas_top) setOffset:12];
         make.size.mas_equalTo(CGSizeMake(25, 25));
    }];
    self.tximg = tximg;
    UILabel *nameLabel = [[UILabel alloc]init];
    nameLabel.text = @"目标:";
    nameLabel.font = [UIFont systemFontOfSize:14];
    [self.contentView addSubview:nameLabel];
    //宽度不够时自适应宽度
    [nameLabel setContentCompressionResistancePriority:UILayoutPriorityRequired
                                               forAxis:UILayoutConstraintAxisHorizontal];
    [nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        [make.left.mas_equalTo(tximg.mas_right) setOffset:8];
        make.bottom.mas_equalTo(tximg);
    }];
    self.nameLabel = nameLabel;
    
    UITextField *dataText = [[UITextField alloc]init];
    dataText.font = [UIFont systemFontOfSize:14];
    [self.contentView addSubview:dataText];
    [dataText mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(nameLabel.mas_right);
        make.bottom.mas_equalTo(tximg);
        make.width.mas_equalTo(135);
    }];
    self.dataText = dataText;
    //下划线
    UILabel *x2label = [[UILabel alloc]init];
    x2label.backgroundColor = [UIColor lightGrayColor];
    [self.contentView addSubview:x2label];
    [x2label mas_makeConstraints:^(MASConstraintMaker *make) {
        [make.left.mas_equalTo(tximg.mas_left) setOffset:-4];
        [make.top.mas_equalTo(tximg.mas_bottom) setOffset:5];
        make.height.mas_equalTo(1);
        [make.right.mas_equalTo(self.contentView.mas_right) setOffset:-20];
    }];
}

-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    [self.dataText resignFirstResponder];
}
@end
